﻿using System;
using System.Collections.Generic;
//
namespace PerceptiveMCAPI_Test
{
   public partial class get_listStaticSegment : System.Web.UI.UserControl
   {
      public ApiMethod method { get; set; }

      public string listId
      {
         get { return tbListId.Text.Trim(); }
         set { tbListId.Text = value; }
      }
      public string name
      {
         get { return tbName.Text.Trim(); }
         set { tbName.Text = value; }
      }
      public int seg_id
      {
         get
         {
            int it; int.TryParse( tbSeg_id.Text.Trim(), out it );
            return it;
         }
         set { tbSeg_id.Text = value.ToString(); }
      }
      public List<string> batch
      {
         get { return ApiHelper.MakeListFromString( tbBatch.Text.Trim() ); }
         set { tbBatch.Text = ApiHelper.MakeStringFromList( value ); }
      }
      // -----------------------------------------------   
      public void Setup()
      {
         lblSection.Text = method.section;
         lblMethod.Text = method.name;
         //
         div_seg_name.Visible = false;
         div_seg_id.Visible = false;
         div_seg_batch.Visible = false;
         //
         switch ( method.name )
         {
            case "listStaticSegments":
               break;
            case "listAddStaticSegment":
               div_seg_name.Visible = true;
               break;
            case "listDelStaticSegment":
            case "listResetStaticSegment":
               div_seg_id.Visible = true;
               break;
            case "listStaticSegmentAddMembers":
            case "listStaticSegmentDelMembers":
               div_seg_id.Visible = true;
               div_seg_batch.Visible = true;
               break;
            default:
               throw new ApplicationException( "unsupported method" );
         }
         //
         tbListId.Focus();
         this.Visible = true;
      }
      // -----------------------------------------------   
   }
}